(function () {

    class Dog {
        name: string
        age: number

        // 构造函数
        // 对象创建时调用
        constructor(name: string, age: number) {
            // this 表示当前类的实例
            this.name = name
            this.age = age
        }

        bark() {
            console.log(this.name)
        }
    }

    const dog = new Dog('1', 1)
    const dog2 = new Dog('2', 2)
    const dog3 = new Dog('3', 3)
    const dog4 = new Dog('4', 4)

    console.log(dog)
    console.log(dog2)
    console.log(dog3)
    console.log(dog4)

    dog2.bark()

})();
